package com.t2c.tibetantochinese.regandlogin;

import android.os.Bundle;
import android.util.Log;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.google.gson.Gson;
import com.t2c.tibetantochinese.R;
import com.t2c.tibetantochinese.base.BaseActivity;
import com.t2c.tibetantochinese.common.HttpRequest;
import com.t2c.tibetantochinese.common.HttpRequestManager;
import com.t2c.tibetantochinese.me.FeedBackActivity;
import com.t2c.tibetantochinese.moudle.Path;
import com.t2c.tibetantochinese.moudle.SearchNetBean;
import com.t2c.tibetantochinese.utils.IntentUtil;
import com.t2c.tibetantochinese.utils.SPUtil;

/**
 * Created by zoulu on 16/10/26.
 * 启动页
 */

public class SplashActivity extends BaseActivity{
//    private ImageView imageview;
    @Override
    protected int getContentViewResId() {
        return R.layout.splash_layout;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        initData();
    }

    private void initView(){
//        imageview = (ImageView) findViewById(R.id.img);
        RelativeLayout logoImage = (RelativeLayout) this.findViewById(R.id.re);
        AlphaAnimation alphaAnimation = new AlphaAnimation(0.1f, 1.0f);
        alphaAnimation.setDuration(3500);
        logoImage.startAnimation(alphaAnimation);
        alphaAnimation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                IntentUtil.gotoMain(SplashActivity.this);
            }
        });
    }

    private void initData(){
//        HttpRequest httpRequest = HttpRequestManager.getInstance().getADimg(new Response.Listener<String>() {
//            @Override
//            public void onResponse(String response) {
//                Path path = new Gson().fromJson(response,Path.class);
//                Glide.with(SplashActivity.this).load(path.getPath()).diskCacheStrategy(DiskCacheStrategy.ALL)  .into(imageview);
//            }
//        }, new Response.ErrorListener() {
//            @Override
//            public void onErrorResponse(VolleyError error) {
//
//            }
//        });
//        httpRequest.commit();
    }
}
